package com.tnmi.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.tnmi.base.entity.Entity;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @version 1.0
 * @Classname MyMetaObjctHandler
 * @Description TODO
 * @Date 2023/7/9 11:26
 * @Created by tnmi
 **/
@Slf4j
@Component
public class MyMetaObjctHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("insert fill....");
        this.strictInsertFill(metaObject, Entity.CREATE_TIME, LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject, Entity.UPDATE_TIME, LocalDateTime.class,LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("update fill....");
        this.strictInsertFill(metaObject, Entity.UPDATE_TIME, LocalDateTime.class,LocalDateTime.now());
    }
}
